/**
 * Created by Administrator on 2017/8/24.
 */
const webpack = require('webpack');
const path = require("path");
const ExtractTextPlugin = require('extract-text-webpack-plugin');


var config = {
    entry: {
        index:path.resolve(__dirname ,"js/main.jsx")
    },//唯一入口文件
    output: {
        path: path.resolve(__dirname ,"./static"),
        filename: "bundle-[name].js",
        publicPath: "/dist/"
    },
    devtool: 'none',
    devServer: {
        contentBase: "./static",//本地服务器所加载的页面所在的目录
        historyApiFallback: true,//不跳转
        inline: true,
        hot: true
    },
    module: {
        rules: [
            {
                test: /(\.jsx|\.js)$/,
                use: {
                    loader: "babel-loader"
                },
                exclude: /node_modules/
            },
            {
                test: /\.css$/,
                use: [
                    {
                        loader: "style-loader"
                    }, {
                        loader: "css-loader",
                        options: {
                            modules: true
                        }
                    }, {
                        loader: "postcss-loader"
                    }
                ]
            }
        ]
    },
    resolve:{
        extensions:[".js",".jsx",".css"]//默认值
    },
    plugins: [
        new webpack.DefinePlugin({
            "process.env": { 
               NODE_ENV: JSON.stringify("production") 
             }
        }),
        new ExtractTextPlugin({
            filename: "css/[name].[contenthash].css"
        }),
        new webpack.optimize.UglifyJsPlugin()
    ],
};

module.exports = config;
